package net.wsfcp.android.http.mvp.presenter;

import net.wsfcp.android.base.BasePresenter;
import net.wsfcp.android.bean.resultbean.BillBean;
import net.wsfcp.android.bean.resultbean.UserAssetsBean;
import net.wsfcp.android.http.mvp.model.BillModel;
import net.wsfcp.android.http.mvp.contract.BillContract;
import net.wsfcp.android.http.mvp.IModel;
import net.wsfcp.android.ui.view.my.activity.BillListActivity;

import java.util.HashMap;

/**
 * Created by Shaoboyang on 2018/12/14.
 */
//我的账单
public class BillPresenter extends BasePresenter<BillListActivity> implements
        BillContract.BillPresenter {

    @Override
    public void getBillList(int page, int pageSize) {
        ((BillModel) getiModelMap().get("bill")).getBillList(page, pageSize, new BillModel
                .BillListInfoHint() {
            @Override
            public void billListSuccessInfo(BillBean bean) {
                getIView().getBillListSuccess(bean);  //成功
            }

            @Override
            public void billListFailInfo(int code, String str) {
                getIView().getBillListFail(code, str);
            }

        });
    }

    //资产总数
    @Override
    public void getTotalAssets() {
        ((BillModel) getiModelMap().get("assets")).getTotalAssets(new BillModel
                .GetTotalAssetsInfoHint() {
            @Override
            public void getTotalAssetsSuccessInfo(UserAssetsBean bean) {
                getIView().getTotalAssetsSuccess(bean);  //成功
            }

            @Override
            public void getTotalAssetsFailInfo(String str) {
                getIView().getTotalAssetsFail(str);  //成功
            }


        });
    }


    @Override
    public HashMap<String, IModel> getiModelMap() {
        return loadModelMap(new BillModel());
    }

    @Override
    public HashMap<String, IModel> loadModelMap(IModel... models) {
        HashMap<String, IModel> map = new HashMap<>();
        map.put("bill", models[0]);
        map.put("assets", models[0]);
        return map;
    }


}
